package com.mr.model;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;

import org.springframework.web.util.HtmlUtils;

import com.mr.util.StringUtil;

public abstract class BaseObject implements Serializable {
	public abstract boolean equals(Object o);
	public abstract int hashCode();
	public String escbr(String propertyname) {
		return esc(propertyname).replaceAll("\n", "<br />");
	}

	public String esc(String propertyname) {
		return escapeHtml(propertyname);
	}

	public String escapeHtml(String propertyname) {
		try {
			String value = org.apache.commons.beanutils.BeanUtils.getProperty(
					this, propertyname);
			if (value == null)
				return "";
			value = HtmlUtils.htmlEscape(value);
			return value;
		} catch (IllegalAccessException e) {
		} catch (InvocationTargetException e) {
		} catch (NoSuchMethodException e) {
		}
		return "";
	}

	public String enabbr(String property, int length) {
		try {
			String value = org.apache.commons.beanutils.BeanUtils.getProperty(
					this, property);
			return StringUtil.enabbr(value, length);
		} catch (Exception e) {
			return "";
		}
	}
}
